CORS(跨源資源共享Cross-Origin Resource Sharing)
當使用者代理請求一個不是目前文件來源
例如來自於不同通訊協定(protocol)、網域(domain)以及通訊埠(port)會建立一個跨來源 HTTP 請求(cross-origin HTTP request)。
參考下面文章解釋,有興趣可以自己深入了解
CORS(跨源資源共享Cross-Origin Resource Sharing)
同源政策 (Same-origin policy)
所謂同源是指兩份網頁具備相同通訊協定(protocol)、網域(domain)以及通訊埠(port)
pip install django-cors-headers 
INSTALLED_APPS = [
    .
    'corsheaders',
    .
]
MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    .
    .
]
CORS_ORIGINS_WHITELIST = [
    "localhost:4200",
]
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_METHODS = [
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT'
]
CORS_ALLOW_HEADERS = [
    "accept",
    "accept-encoding",
    "authorization",
    "content-type",
    "dnt",
    "origin",
    "user-agent",
    "x-csrftoken",
    "x-requested-with",
]